<?php
include("setup.php");

$sensors = array();
foreach($config->get("sensors", array()) as $name => $values) {
	$data = new Config_Dataset($values);
	$displayName = $data->get("name", $name);
	$sensors[$displayName] = new Rrd_Database($displayName, $name);
}

?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title><?php echo $config->get("title", "Temperature"); ?></title>
		<meta http-equiv="refresh" content="30">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href="css/bootstrap.min.css" rel="stylesheet" />
		<link href="css/bootstrap-responsive.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
	</head>
	<body>
		<div class="body">
			<div class="top">
				<h1><?php echo $config->get("title", "Temperature"); ?></h1>
			</div>
			<div class="content small-container">
<?php foreach($sensors as $name => $db) { ?>
				<div class="panel small">
					<h1><?php echo $name; ?></h1>
					<dl class="dl-horizontal">
						<dt class="current">Current:</dt><dd class="current"><?php echo $db->getCurrent(); ?></dd>
						<dt>Avarage:</dt><dd><?php echo $db->getAvg(); ?></dd>
						<dt>Max:</dt><dd><?php echo $db->getMax(); ?></dd>
						<dt>Min:</dt><dd><?php echo $db->getMin(); ?></dd>
					</dl>
				</div>
<?php } ?>
			</div>
			<div class="content" id="graph">
				<div class="panel">
					<h1>Day</h1>
					<img src="img/graph/graph_d.png"></img>
				</div>
				<div class="panel">
					<h1>Week</h1>
					<img src="img/graph/graph_w.png"></img>
				</div>
				<div class="panel">
					<h1>Month</h1>
					<img src="img/graph/graph_m.png"></img>
				</div>
				<div class="panel">
					<h1>Year</h1>
					<img src="img/graph/graph_y.png"></img>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/bootstrap.js"></script>
	</body>
</html>
